package code.controllers;

import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.portlet.ModelAndView;
import org.springframework.web.portlet.bind.annotation.RenderMapping;


import code.service.IPhraseService;

@Controller(value = "myController")
@RequestMapping("VIEW")
public class PhraseController 
{
	@Autowired
	@Qualifier("myService")
	private IPhraseService phraseService;

	public void setPhraseService(IPhraseService phraseService) 
	{
		this.phraseService = phraseService;
	}

	@RenderMapping
	protected ModelAndView handleRenderRequestInternal(
			final RenderRequest request, final RenderResponse response) 
	{
		ModelAndView modelAndView = new ModelAndView("View");
		modelAndView.addObject("best_phrase", phraseService.getPhrase());
		return modelAndView;
	}
}
